﻿using BuzzX8.Xmpp.StreamElements.Stanza;

namespace BuzzX8.Xmpp.StreamElements.Builders
{
    public abstract class StanzaBuilder<TType, TStanza> : DatagramElementBuilder<TStanza> where TStanza : Stanza<TType>
    {
        protected override void AddAttributeToRootElement(string name, string value)
        {
            if (name == "type") RootElement.Type = GetStanzaTypeForAttributeValue(value);
            else base.AddAttributeToRootElement(name, value);
        }

        protected abstract TType GetStanzaTypeForAttributeValue(string value);
    }
}
